// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import Login from './components/login'
import router from './router'
import { sync } from 'vuex-router-sync'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

// import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'

import prototype from'../static/js/sysProp.js'

Vue.use(VueAxios, axios)
Vue.use(Element)
Vue.config.productionTip = false
Vue.use(prototype)

/*sync(store, router)*/

import '../static/css/reset.css'
import '../static/css/common.css'
new Vue({
  el: '#app',
  router,
  render:h=>h(App),
  watch: {
        "$route": 'checkLogin'
    },
    //进入页面时
    created() {
        this.checkLogin()
    },
    methods: {
        checkLogin() {
            if (!this.getCookie('a-user')) {
                //如果没有登录状态则跳转到登录页
                this.$router.push('/login')
            } else {
                if(this.$route.path == '/login') {
                    this.$router.push('/home/activity/list')
                }
            }
        }
    }
  //components: { App },
  //template: '<App/>'
}).$mount("#app")
